<?php
/**
 * 提醒：奖励、私信
 */

class NotificationModel
{
    public function __construct()
    {
    }

    public function getLastest($user_id)
    {
        $db = new NotificationDb();
        $where = array(
            'e' => array(
                'user_id' => $user_id,
            ),
        );
        return $db->selectRows($where, '*', 0, 10, '','create_time DESC');
    }

    public function countUnreaded($user_id)
    {
        $db = new NotificationDb();
        $where = array(
            'e' => array(
                'user_id' => $user_id,
                'is_readed' => 0,
            ),
        );
        return $db->selectCount($where);
    }

    public function getUnreaded($user_id)
    {
        $db = new NotificationDb();
        $where = array(
            'e' => array(
                'user_id' => $user_id,
                'is_readed' => 0,
            ),
        );
        return $db->selectRows($where, '*', 0, '', '','create_time DESC');
    }

    public function markReaded($user_id)
    {
        $db = new NotificationDb();
        $where = array(
            'e' => array(
                'user_id' => $user_id,
                'is_readed' => 0,
            ),
        );
        $data = array(
            'is_readed' => 1,
        );
        return $db->update($data, $where);
    }
}
?>
